import 'package:flutter/material.dart';
import 'package:vmall_app/models/nav_item.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  // This widget is the root of your application.
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  var selectedIndex = 0;
  final List<Widget> homePages = List();
  List<BottomNavigationBarItem> bottomNavBars = List();
  @override
  void initState() {
    listNavItem.forEach((item) => homePages.add(item.page));
    listNavItem.forEach((item) {
      bottomNavBars.add(BottomNavigationBarItem(
          icon: item.icon, activeIcon: item.fillIcon, title: Text(item.name)));
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
            primaryColor: Colors.redAccent,
            bottomAppBarTheme:
                BottomAppBarTheme(color: Colors.transparent, elevation: 10.0)),
        home: Scaffold(
            body: homePages[selectedIndex],
            bottomNavigationBar: BottomNavigationBar(
                type: BottomNavigationBarType.fixed,
                fixedColor: Colors.deepOrange[400],
                backgroundColor: Colors.white,
                unselectedItemColor: Colors.grey,
                unselectedLabelStyle: TextStyle(color: Colors.grey),
                showUnselectedLabels: true,
                currentIndex: selectedIndex,
                onTap: (index) {
                  setState(() {
                    selectedIndex = index;
                  });
                },
                items: bottomNavBars)));
  }
}
